package com.sast.data_system_backend.common;

import lombok.Data;

@Data
public class Response<T> {
    private T data;
    private String message;
    private int code;

    public static <K> Response<K> newSuccess(K data) {
        Response<K> response = new Response<>();
        response.setData(data);
        response.setCode(0);
        return response;
    }

    public static Response<Void> newError(int code, String errorMessage) {
        Response<Void> response = new Response<>();
        response.setCode(code);
        response.setMessage(errorMessage);
        return response;
    }

    public static Response<Void> newError(ErrorCode errorCode, String errorMessage) {
        Response<Void> response = new Response<>();
        response.setCode(errorCode.getCode());
        response.setMessage(errorMessage);
        return response;
    }


}
